﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.HTML
{
    #region Using Statements

    using System;
    using System.Linq;

    #endregion

    /// <summary>
    /// Client-side image map. See the MAP element definition in HTML 4.01.
    /// </summary>
    public class HTMLMapElement : HTMLElement
    {
        #region Constructors

        internal HTMLMapElement(Document owner)
            : base(owner, HTMLConstants.HTML_TAG_MAP)
        {
        }

        #endregion

        #region Level 2 DOM HTML Compliance

        /// <summary>
        /// The list of areas defined for the image map.
        /// </summary>
        public HTMLCollection areas
        {
            get
            {
                return new HTMLCollection(Owner, getElementsByTagName(HTMLConstants.HTML_TAG_AREA).Nodes);
            }
        }

        /// <summary>
        /// Names the map (for use with usemap). 
        /// See the name attribute definition in HTML 4.01.
        /// </summary>
        public string name
        {
            get
            {
                return getAttribute(HTMLConstants.HTML_ATT_NAME);
            }
            set
            {
                if (String.IsNullOrEmpty(value))
                    removeAttribute(HTMLConstants.HTML_ATT_NAME);
                else
                    setAttribute(HTMLConstants.HTML_ATT_NAME, value);
            }
        }

        #endregion
    }
}
